/**
 * 
 */
package com.google.gwt.sample.stockwatcher.client;

/**
 * @author Prashanth
 *
 */
import com.google.gwt.user.client.rpc.AsyncCallback; 
import com.google.gwt.user.client.ui.SuggestOracle; 

public class ItemSuggestOracle extends SuggestOracle { 
	
	public ItemSuggestOracle(){
	}
    public boolean isDisplayStringHTML() { return true; } 
    public void requestSuggestions(SuggestOracle.Request req, 
SuggestOracle.Callback callback) { 
    	
        ItemSuggestService.Util.getInstance().getSuggestions(req, new 
ItemSuggestCallback(req, callback)); 
    } 
    class ItemSuggestCallback implements AsyncCallback { 
        private SuggestOracle.Request req; 
        private SuggestOracle.Callback callback; 
        public ItemSuggestCallback(SuggestOracle.Request _req, 
SuggestOracle.Callback _callback) { 
            req = _req; 
            callback = _callback; 
        } 
        public void onFailure(Throwable error) { 
        	System.out.println(error.getMessage());
        	System.out.println("failure");
            callback.onSuggestionsReady(req, new 
SuggestOracle.Response()); 
        } 
        public void onSuccess(Object retValue) { 
        	System.out.println("success");
            callback.onSuggestionsReady(req, 
(SuggestOracle.Response)retValue); 
        } 
    } 
} 
